package com.dianping.cat.consumer.event.model.transform;
import com.dianping.cat.consumer.event.model.entity.EventName;
import com.dianping.cat.consumer.event.model.entity.EventReport;
import com.dianping.cat.consumer.event.model.entity.EventType;
import com.dianping.cat.consumer.event.model.entity.GraphTrend;
import com.dianping.cat.consumer.event.model.entity.Machine;
import com.dianping.cat.consumer.event.model.entity.Range;
import com.dianping.cat.consumer.event.model.entity.StatusCode;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/*  16 */     this.m_deferedJobs = new ArrayList();


/*  19 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/*  23 */     for (Runnable job : this.m_deferedJobs) {
      job.run();
    }
  }


  public boolean onGraphTrend(EventType parent, GraphTrend graphTrend) {
/*  30 */     parent.setGraphTrend(graphTrend);
    return true;
  }


  public boolean onGraphTrend(EventName parent, GraphTrend graphTrend) {
    parent.setGraphTrend(graphTrend);
/*  37 */     return true;
  }


  public boolean onMachine(final EventReport parent, final Machine machine) {
/*  42 */     if (this.m_deferrable) {
/*  43 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  46 */               parent.addMachine(machine);
            }
          });
    } else {
/*  50 */       parent.addMachine(machine);
    }

/*  53 */     return true;
  }


  public boolean onName(final EventType parent, final EventName name) {
/*  58 */     if (this.m_deferrable) {
/*  59 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  62 */               parent.addName(name);
            }
          });
    } else {
/*  66 */       parent.addName(name);
    }

/*  69 */     return true;
  }


  public boolean onRange(final EventName parent, final Range range) {
/*  74 */     if (this.m_deferrable) {
/*  75 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
              parent.addRange(range);
            }
          });
    } else {
/*  82 */       parent.addRange(range);
    }

/*  85 */     return true;
  }


  public boolean onStatusCode(final EventName parent, final StatusCode statusCode) {
/*  90 */     if (this.m_deferrable) {
/*  91 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  94 */               parent.addStatusCode(statusCode);
            }
          });
    } else {
/*  98 */       parent.addStatusCode(statusCode);
    }

/* 101 */     return true;
  }


  public boolean onType(final Machine parent, final EventType type) {
/* 106 */     if (this.m_deferrable) {
/* 107 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 110 */               parent.addType(type);
            }
          });
    } else {
/* 114 */       parent.addType(type);
    }

/* 117 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/event/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */